from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

# 初始化Chrome浏览器
driver = webdriver.Chrome()

# 打开百度首页
driver.get("https://www.baidu.com")
driver.maximize_window()

try:
    # 定位搜索按钮
    search_button = driver.find_element(By.ID, "su")
    print("搜索按钮是否可用：", search_button.is_enabled())

except Exception as e:
    print("判断元素是否可用失败：", e)

finally:
    sleep(5)  # 休眠5秒供截图
    driver.quit()